# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=schroedinger
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.11
pkgrel=6
pkgdesc="An implemenation of the Dirac video codec in ANSI C code (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="http://www.diracvideo.org/"
license=('GPL2' 'LGPL2.1' 'MPL' 'MIT')
depends=("${MINGW_PACKAGE_PREFIX}-orc")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc")
source=(#"http://www.diracvideo.org/download/schroedinger/${_realname}-${pkgver}.tar.gz"
        https://download.videolan.org/contrib/${_realname}-${pkgver}.tar.gz
        0001-builddir-not-srcdir.all.patch
        0002-link-testsuite-to-orc-tmp.mingw.patch
        0003-add-process-h-for-beginthreadex.patch)
sha256sums=('1e572a0735b92aca5746c4528f9bebd35aa0ccf8619b22fa2756137a8cc9f912'
            '215a8a964a1d7aaa8cb23aa5420892f6c970e4ecde1a55e7fcf13054749be73c'
            '4178960ea60e90917fc77d0dd231db83ba55a3621c3c40471a2bd9efa872ea6e'
            '1c8f58e5095e5a11099d8579b5aa9767df310046cc84e4b3d032f160bf078e64')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}"/0001-builddir-not-srcdir.all.patch
  patch -p1 -i "${srcdir}"/0002-link-testsuite-to-orc-tmp.mingw.patch
  patch -p1 -i "${srcdir}"/0003-add-process-h-for-beginthreadex.patch
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --with-opengl=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
}
